package com.alks.function.controller.pcFactoryQuery;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.factoryquery.StitchStockRequest;
import com.alks.function.service.pcfactoryquery.IPcStitchDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@ApiRestController("/pcFactorQuery")
@Api(value = "总经办", tags = "总经办-工厂查询模块-鞋面入库查询")
@Slf4j
@RoleCheck(prgIds = {"100417", "140209", "160215", "170514", "110309", "130307", "180715", "190214", "210207"})
public class StitchInController {
    @Autowired
    private IPcStitchDetailService stitchService;

    @PutMapping("/queryStitchStockHead")
    @ApiOperation(value = "鞋面入库-鞋面入库主表-条件分页查询", tags = "总经办-工厂查询模块-鞋面入库查询")
    @WebLogger
    public ResponseInfo queryStitchStockHead(@RequestBody StitchStockRequest request) {
        return stitchService.queryStitchStockHead(request);
    }

    @GetMapping("/queryStitchStockDetail")
    @ApiOperation(value = "鞋面入库-鞋面入库明细-条件查询", tags = "总经办-工厂查询模块-鞋面入库查询")
    @WebLogger
    public ResponseInfo queryStitchStockDetail(@RequestParam(value = "lotNo", required = false) String lotNo) {
        return stitchService.queryStitchStockDetail(lotNo);
    }

    @GetMapping("/stitchIn/back")
    @ApiOperation(value = "回显", tags = "总经办-工厂查询模块-鞋面入库查询")
    @WebLogger
    public ResponseInfo deptNameBack(@RequestParam(required = false) String search) {
        return stitchService.deptNameBack(search);
    }

    @GetMapping("/updateStitchStatus")
    @ApiOperation(value = "更新鞋面库存", tags = "总经办-工厂查询模块-鞋面入库查询")
    @WebLogger
    public ResponseInfo updateStitchStatus() {
        return stitchService.updateStitchStatus();
    }

    @PostMapping("/frozenStitch")
    @ApiOperation(value = "冻结指令(鞋面不能入库)", tags = "总经办-工厂查询模块-鞋面入库查询")
    @WebLogger
    public ResponseInfo frozenStitch(@RequestBody List<String> lotNoList) {
        return stitchService.frozenStitch(lotNoList);
    }

    @PostMapping("/cancelFrozenStitch")
    @ApiOperation(value = "取消冻结指令", tags = "总经办-工厂查询模块-鞋面入库查询")
    @WebLogger
    public ResponseInfo cancelFrozenStitch(@RequestBody List<String> lotNoList) {
        return stitchService.cancelFrozenStitch(lotNoList);
    }

}
